{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1. 转义字符与原字符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\n",
      "world\n",
      "hello\tworld\n",
      "helloooo\tworld\n",
      "hello\r",
      "world\n",
      "hello\bworld\n",
      "http:\\\\www.baidu.com\n",
      "老师说：\\‘大家好\\’\n",
      "hello\\n world\n",
      "hello\\n world\\\\\n"
     ]
    }
   ],
   "source": [
    "# 转义字符\n",
    "print('hello\\nworld') # \\+转义功能的首字符   n--newline的首字符表示换行\n",
    "\n",
    "print('hello\\tworld') # \\t用了三个位置\n",
    "\n",
    "print('helloooo\\tworld') # \\t用了四个位置\n",
    "\n",
    "print('hello\\rworld') # return  回车 只剩下world将hello进行了覆盖\n",
    "\n",
    "print('hello\\bworld') # back 退格 少一个o\n",
    "\n",
    "print('http:\\\\\\\\www.baidu.com')  # \\\\打印出来是一个\\\n",
    "\n",
    "print('老师说：\\‘大家好\\’') # \\是转义字符\n",
    "\n",
    "print(r'hello\\n world') # 原字符，不希望字符串中的转义字符起作用，就使用原字符，就是在字符串之前加上r或R\n",
    "\n",
    "#print(r'hello\\n world\\') # 最后一个字符不能是反斜线\\\n",
    "print(r'hello\\n world\\\\') # 最后一个字符可以是两个\\\\"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.6.3",
   "language": "python",
   "name": "python3.6.3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
